package com.baosight.sczx.common.zm.cInterface.cl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;

public class RoundCheckWorkNote {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	
	/**
	 * <p>Function: queryNoteCode</p>
	 * <p>Description: 新增隐患和三违时用到的巡检工单编号</p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-6-21下午     高强
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static EiBlock getAllNoteCode(String _blockID, boolean isAll) {
		List<Map>  _list = new ArrayList<Map>();
		_blockID = _blockID == null ? "cmes.cl.workNoteCode" : _blockID;
		
		EiBlock block = new EiBlock(_blockID);

		EiColumn eiColumn = new EiColumn("value");
		eiColumn.setType("C");
		block.addMeta(eiColumn);

		eiColumn = new EiColumn("display");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		Map para = new HashMap();
		para.put("fdStatus", "发单");
		if(isAll) {
			Map<String, String> _map = new HashMap<String, String>();
			_map.put("value", "");
			_map.put("display", "");
			_list.add(_map);
		
			try {
				
				List<Map> _temp = dao.query("ZMCLRoundcheckWorknote.queryInterface", para) == null ? new ArrayList<Map>():dao.query("ZMCLRoundcheckWorknote.queryInterface", para);
				for(int i = 0; i < _temp.size(); i++) {
					_list.add(_temp.get(i));
				}
				
			} catch (Exception e) {
				
			}
		}
		else {
			_list = dao.query("ZMCLRoundcheckWorknote.queryInterface", para);
		}
		
		block.setRows(_list);
		return block;
	}
	
	/**
	 * 查询到被引用巡检工单的列表
	 * <p>Function: queryNoteCode</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-13下午12:40:44 张志芳
	 * </p>
	 *
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static List<Map> queryNoteCode(String keyId)
	{
		List<Map>  _list = new ArrayList();
		try{
			Map para = new HashMap();
			para.put("fdSecuritypathId", keyId);
			_list = dao.query("ZMCLRoundcheckWorknote.queryInterface", para);
			
		}catch(Exception e){
			return _list;
		}
		return _list;
	}
}
